1 Introduction

Analysis of EECA’s Energy End Use Data for New Zealand.

2 Data

dataFile <- path.expand("~/Dropbox/data/EECA/eeud_data-2024-08-16-657.csv")

dt <- data.table::fread(dataFile)

The data gives total energy used (TJ) per year for different purposes by different sectors and by type.

For example, Figure 2.1 shows total energy use over time by sector group while Figure 2.2 shows the total by energy (fuel) type.

make_colPlot <- function(dt, xVar, yVar, fillVar, scaleVar){
  p <- ggplot2::ggplot(dt, aes(x = get(xVar), 
                               y = get(yVar), 
                               fill = get(fillVar))) +
    geom_col() +
    scale_fill_discrete(name = scaleVar)
  return(p)
}

plotDT <- dt[, .(Total_TJ = sum(TJ,na.rm = TRUE)),
             keyby = .(SectorGroup, Period)]

make_colPlot(plotDT, "Period", "Total_TJ", "SectorGroup", "Sector") +
  labs(x = "Year", y = "Total TJ")
Energy use by sector over time

Figure 2.1: Energy use by sector over time

message("2022 total")
## 2022 total
sum(plotDT[Period == 2022, Total_TJ])
## [1] 541085.4
plotDT <- dt[, .(Total_TJ = sum(TJ, na.rm = TRUE)),
             keyby = .(FuelGroup, Period)]

make_colPlot(plotDT, "Period", "Total_TJ", "FuelGroup", "FuelGroup") +
  labs(x = "Year", y = "Total TJ")
Energy use by fuel group over time

Figure 2.2: Energy use by fuel group over time

message("2022 total")
## 2022 total
sum(plotDT[Period == 2022, Total_TJ])
## [1] 541085.4
plotDT <- dt[Fuel %like% "Electricity", .(Total_TJ = sum(TJ, na.rm = TRUE)),
             keyby = .(SectorGroup, Period)]

make_colPlot(plotDT, "Period", "Total_TJ", "SectorGroup", "SectorGroup") +
  labs(x = "Year", y = "Total TJ")
Electricity use by sector over time

Figure 2.3: Electricity use by sector over time

message("2022 total electricity")
## 2022 total electricity
sum(plotDT[Period == 2022, Total_TJ])
## [1] 138548.1

3 Residential electricity use

ggplot2::ggplot(dt[Fuel %like% "Electricity" &
                     Sector %like% "Residential"],
                aes(x = Period, y = TJ, fill = EndUseGroup)) +
  geom_col(position = "stack")

elec_tj <- dt[Fuel %like% "Electricity"]
elec_tj[, TJ_pc := 100 * TJ/sum(TJ, na.rm = TRUE), keyby = .(Period)]

resElec_2022_pc <- sum(elec_tj[Period == 2022 &
                                 Sector %like% "Residential", TJ_pc])
resElec_2022 <- sum(elec_tj[Period == 2022 &
                                 Sector %like% "Residential", TJ])

resElec_2022_spaceHeat <- sum(elec_tj[Period == 2022 &
                                 Sector %like% "Residential" &
                                   EndUse %like% "Space Heating", TJ])
resElec_2022_spaceHeat_pc <- sum(elec_tj[Period == 2022 &
                                 Sector %like% "Residential" &
                                   EndUse %like% "Space Heating", TJ_pc])
p <- ggplot2::ggplot(dt[Fuel %like% "Electricity" &
                     Sector %like% "Residential" &
                                   EndUse %like% "Heat"],
                aes(x = Period, y = TJ, 
                    fill = Technology
                    )) +
  geom_col(position = "stack") +
  theme(legend.position = "bottom")

plotly::ggplotly(p)

Figure 3.1: Electricity used for heat

2022

  • residential = 46,792.07 TJ (33.8 % of all electricity)
  • residential space heating = 9,487.372 TJ (6.8 % of all electricity)
ggplot2::ggplot(elec_tj[Sector %like% "Residential" &
                          EndUse %like% "Space Heat"], aes(x = Period,
                        y = TJ,
                        colour = Technology))+
  geom_line()

  # theme(legend.position = "bottom") +
  # guides(colour=guide_legend(ncol=1))


ggplot2::ggplot(elec_tj[Sector %like% "Residential" &
                          EndUse %like% "Space Heat"], aes(x = Period,
                        y = TJ_pc,
                        colour = Technology))+
  geom_line() +
  labs(y = "% total electricity")